package com.eascs.admin.o2o.internal.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eascs.admin.common.service.BaseSevice;
import com.eascs.admin.o2o.internal.dao.O2oOaDao;
import com.eascs.admin.o2o.internal.dao.O2oOaUpdateDao;
import com.eascs.admin.o2o.internal.entity.OaDeposit;
import com.eascs.admin.o2o.internal.entity.OaLoanapply;
import com.eascs.admin.o2o.internal.entity.OaStatus;
import com.eascs.overdue.dao.O2oOverdueReportDao;
import com.eascs.overdue.entity.O2oStatus;
/**
 * 旧系统 主表service
 * @author ycz
 *
 */
@Service
public class OaLoanapplyService  extends BaseSevice{
	@Autowired
	private O2oOaDao o2oOaDao;
	@Autowired
	private O2oOaUpdateDao o2oOaUpdateDao;
	@Autowired
	private O2oOverdueReportDao o2oOverdueReportDao;
	/**
	 * 查询旧系统主表信息
	 * @param billcode
	 * @return
	 */
	public OaLoanapply queryBillCode(String billCode){
		return o2oOaDao.queryCode(billCode);
	}
	/**
	 * 更新旧系统主表  已退和已收保证金字段
	 * @param oaLoanapply
	 */
	public int updateOaLoanapply(OaLoanapply oaLoanapply){
		return o2oOaUpdateDao.updateLoanapply(oaLoanapply);
	}
	/**
	 * 校验上笔贷款身份证、姓名 与 当前借款人身份证、姓名是否匹配
	 * @param loanapplyNo
	 * @param loanername
	 * @param idCard
	 * @return
	 */
	public int  isNotExistLoanUser(String loanapplyNo,String loanername,String idCard){
		String sql="SELECT COUNT(1) FROM EADB.O2O_LOANER T WHERE T.LOANERNAME=? AND T.IDCARD=? AND T.LOANAPPLYNO=? ";
		return o2oOaDao.findInteger(sql, loanername,idCard,loanapplyNo);
	}
	/**
	 * 查询是否可以正在退款
	 * @param billCode
	 * @return
	 */
	public OaStatus queryBackDeposit(String billCode){
		return o2oOaDao.queryBackDeposit(billCode);
	}
	/**
	 * 查询借款人是否有逾期
	 * @param billCode
	 * @return
	 */
	public List<O2oStatus> findOverdueBillCode(String billCode){
		return o2oOverdueReportDao.findCode(billCode);
	}
	/**
	 * 查询可以退保证金老系统和新系统单号
	 * @param idCard
	 * @return
	 */
	public List<OaDeposit> findBillCode(String idCard,List<OaDeposit> billCodeList){
		return o2oOaDao.findBillCode(idCard);
	}
}
